<template>
  <AvicModal :visible="true" title="添加" width="960px" height="520.17px" :centered="true" @cancel="closeModal">
    <div style="background-color: #ffffff; padding: 16px">
      <a-form ref="formRef" :model="form" :rules="rules" :label-col="{ flex: '0 0 140px' }" :wrapper-col="{ flex: '1 1 0' }" class="">
        <a-row>
          <a-col :span="12">
            <a-form-item name="code" label="编码">
              <a-input v-model:value="form.code" placeholder="请输入编码" :maxlength="66" />
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item name="cnName" label="中文名称">
              <a-input v-model:value="form.cnName" placeholder="请输入中文名称" :maxlength="66" />
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item name="desc" label="描述">
              <a-input v-model:value="form.desc" placeholder="请输入描述" :maxlength="66" />
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item name="secretLevel" label="密级">
              <AvicSecretSelect
                v-model:value="form.secretLevel"
                :get-popup-container="(triggerNode) => triggerNode.parentNode"
                option-filter-prop="children"
                placeholder="请选择密级"
              />
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item name="enName" label="英文名称">
              <a-input v-model:value="form.enName" placeholder="请输入英文名称" :maxlength="66" />
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <template #footer>
      <a-button title="保存" type="primary" :loading="loading" @click="saveForm">保存</a-button>
      <a-button title="返回" type="primary" ghost @click="closeModal">返回</a-button>
    </template>
  </AvicModal>
</template>
<script lang="ts" setup>
import { useDataEntityForm, emits } from './ts/DataEntityForm'; // 引入表单ts
const props = defineProps({
  formId: {
    type: String,
    default: ''
  }
});
defineEmits(emits);
const { formRef, loading, saveForm, closeModal, rules, form } = useDataEntityForm(props, 'add');
</script>
